<?php
$this->beginWidget('bootstrap.widgets.TbBox', array(
	'title' => array($this->projectName => array('project/schema'), '数据列表'),
	'headerIcon' => 'icon-list',
));
?>
<div class="row-fluid row-top">
	<div class="span8 input-append">
		<?php
		echo CHtml::beginForm(array($this->route), 'get', array('class' => 'search form-inline'));
		$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
			'name' => 'q',
			'value' => $q,
			'sourceUrl' => array('project/suggest'),
			'options' => array(
				'minLength' => '1',
				'select' => 'js:function(ev,ui){$(\'form.search input.span10\').val(ui.item.label);$(\'form.search\').submit();}',
			),
			'htmlOptions' => array(
				'class' => 'span10',
				'maxlength' => '80',
				'placeholder' => '请输入关键词...',
			),
		));
		$this->widget('bootstrap.widgets.TbButton', array(
			'type' => 'primary',
			'buttonType' => 'submit',
			'label' => '搜索',
		));
		echo CHtml::endForm();
		?>
	</div>
	<div class="span4 text-right">
		<?php
		$this->widget('bootstrap.widgets.TbButton', array(
			'type' => 'normal',
			'label' => '添加数据',
			'url' => array('create'),
		));
		?>
	</div>
</div>
<div id="data-list-top"><span></span></div>
<?php
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
	'id' => 'data-list',
	'type' => 'striped bordered',
	'dataProvider' => $gridDataProvider,
	'rowCssClassExpression' => '$data->getIsRemoved()?"removed":""',
	'template' => "{summary}\n{items}\n{pager}",
	'summaryText' => '第 {start} - {end} 条，共计 {count} 条。',
	'bulkActions' => array(
		'align' => 'left',
		'actionButtons' => array(
			array(
				'id' => 'del-checked',
				'buttonType' => 'button',
				'type' => 'primary',
				'size' => 'small',
				'label' => '删除选中的',
				'click' => 'js:delChecked'
			)
		),
		'checkBoxColumnConfig' => array(
			'name' => $model->getXS()->getFieldId()->name,
		),
	),
	'columns' => $gridColumns,
));
?>
<div class="well well-small">
	<code><?php echo $model->xs->search->query; ?></code>
</div>
<?php $this->endWidget(); ?>
<script type="text/javascript" pos="ready">
	function delChecked(values)
	{
		var ids = '';
		$.each(values, function(i, v) {
			ids += '&id[]=' + v.value;
		});
		$.get("<?php echo $this->createUrl('data/delete'); ?>" + ids, function(msg) {
			window.location.reload();
		});
	}
	$('#data-list-top').scroll(function(){
		$('#data-list').scrollLeft($(this).scrollLeft());
	});
	$('#data-list').scroll(function(){
		$('#data-list-top').scrollLeft($(this).scrollLeft());
	});
	$('#data-list-top span').css('width', $('#data-list table').outerWidth());
</script>
